]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
swipeTracker: Simplify finding previous point
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 20 Nov 2025 13:34:21 +0000 (14:34 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 20 Nov 2025 13:34:21 +0000 (14:34 +0100)
We have findLastIndex() nowadays to search an array in reverse
direction.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3967>

js/ui/swipeTracker.js

index 1beecf8b64e87397c56d32605942463a27af86ff..30afdef7b1dd9c7f940f8cfbf6608d4795acd670 100644 (file)
@@ -523,8 +523,7 @@ export const SwipeTracker = GObject.registerClass({
     }
 
     _findPreviousPoint(pos) {
-        const reversedIndex = this._snapPoints.slice().reverse().findIndex(p => p <= pos);
-        return this._snapPoints.length - 1 - reversedIndex;
+        return this._snapPoints.findLastIndex(p => p <= pos);
     }
 
     _findPointForProjection(pos, velocity) {